/*
 *  logging.h - log/cache data
 *  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _LOGGING_H
#define _LOGGING_H

typedef struct log_data
{
    char   *path;
    char   *dir;
    char   *file;
} log_data;

/**
 *  Attempts to create all the files in PATH if they do not exist
 *
 *  param path: path to the file you wish to log too.
 *
 *  return: log_st pointer
 *          NULL on error
 */
int log_init (struct log_data *ld, const char *dir, const char *file);

/**
 *  writes KEY:VALUE to ld->file
 *
 *  param ld: log_data pointer returned by log_init()
 *
 *  param key: the identifier of the value you wish to cache
 *
 *  param value: the value you wish to cache
 *
 *  return: 0 on success
 *          -1 on failure
 */
int     cache_value (struct log_data * ld, const char *key, const char *value);

/**
 *  reads KEY:VALUE from ld->file
 *
 *  param ld: log_data pointer returned by log_init()
 *
 *  param key: the identifier of the value you wish to retreive
 *
 *  return: value of the specified key
 *          NULL on error
 */
char   *get_cached_value (struct log_data * ld, char *key);

/**
 *  Free's the memory allocated by log_data and its members.
 *
 *  param ld: log_data pointer returned by log_init();
 */
void    log_free (struct log_data *ld);
#endif /* _LOGGING_H */
